package cn.com.customer.manager.ui.message.messageMian

import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import cn.com.customer.manager.R
import cn.com.customer.manager.adapter.BasePagerAdapter
import cn.com.customer.manager.base.BaseActivity
import cn.com.customer.manager.ui.message.email.EmailFragment
import cn.com.customer.manager.ui.message.msg.MessageFragment
import cn.com.customer.manager.ui.message.notice.NoticeFragment
import cn.com.customer.manager.ui.message.phone.PhoneFragment
import kotlinx.android.synthetic.main.fragment_message.*


/**
 *消息
 */
class MessageActivity : BaseActivity(), ViewPager.OnPageChangeListener, MessageMainContract.View {
    private val fragments: ArrayList<Fragment> = ArrayList(5)
    private var mPresenter: MessageMainContract.Presenter = MessageMainPresenter(this)
    override fun getLayoutId(): Int = R.layout.fragment_message
    override fun initView(savedInstanceState: Bundle?) {
        fragments.clear()
        fragments.add(NoticeFragment.newInstance(0))
        fragments.add(NoticeFragment.newInstance(1))
        fragments.add(MessageFragment.newInstance())
        fragments.add(EmailFragment.newInstance())
        fragments.add(PhoneFragment.newInstance())
        initTabLayout()
    }

    /**
     * 设置TabLayout
     */
    private fun initTabLayout() {
        val titles = arrayOf(getString(R.string.system), getString(R.string.instation), getString(R.string.sms), getString(R.string.email), getString(R.string.call))
        viewPager.adapter = BasePagerAdapter(this!!.supportFragmentManager, fragments, titles)
        viewPager.addOnPageChangeListener(this)
        tabLayout.setupWithViewPager(viewPager)
    }

    override fun onPageScrollStateChanged(state: Int) {

    }

    override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {

    }

    override fun onPageSelected(position: Int) {
    }

    override fun setPresenter(presenter: MessageMainContract.Presenter) {
        mPresenter = presenter
    }


}

